import { createSlice, type PayloadAction } from "@reduxjs/toolkit";

export type UserStateType = {
  username: string;
  nickname: string;
};

const INIT_STATE: UserStateType = { username: "", nickname: "" };
export const userSlize = createSlice({
  name: "user",
  initialState: INIT_STATE,
  reducers: {
    loginReducer: (
      state: UserStateType,
      action: PayloadAction<UserStateType>
    ) => {
      return action.payload;
    },
    logoutReducer: () => INIT_STATE,
  },
});
export const { loginReducer, logoutReducer } = userSlize.actions;
export default userSlize.reducer;
